package org.whuims.core.dataprocessor;

import org.whuims.core.utils.Mysql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Qikai on 2016/11/10.
 */
public class ReferenceUpdater {
    public static void main(String[] args) {
        Connection conn = Mysql.getConn("stdmem");
        List<String> list = new ArrayList<String>();
        try {
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("select reference from std_std");
            while (rs.next()) {
                String line = rs.getString("reference");
                if (line == null) {
                    continue;
                }
                System.out.println(line);
                String[] array = line.split("[;;]");
                for (String str : array) {
                    if (str.matches("\\w+.+?")) {
                        System.out.println("\t\t" + str);
                        list.add(str.trim());
                    }
                }
            }
            rs.close();
            for (String str : list) {
//                stmt.execute("insert into std_std(name,valid) values('"+str+"', 0"+")");
            }
            stmt.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
